package com.example.springboot.config.postProcessor.beanfactorypostprocessor;

import com.example.springboot.compoent.CZK;
import org.springframework.aop.interceptor.AsyncExecutionAspectSupport;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/8/1 15:01
 */
@Component
public class PrimaryBeanProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("===优先执行===");

        // 这个里获取bean会优先初始化bean,早于其他bean初始化

        CZK bean = beanFactory.getBean(CZK.class);

        bean.print();

        System.out.println(AsyncExecutionAspectSupport.class);

    }

}


